package work;

public class MinMajority {

    public static void main(String[] args) {
        System.out.println(leastMajorityMultiple(1, 2, 3, 4, 5));
    }

    /******************************************
     * 在这里输入代码
     * 你不需要写main函数，系统将自动调用leastMajorityMultiple函数
     ******************************************/
    public static int leastMajorityMultiple(int a, int b, int c, int d, int e) {
        int arr[] = {a, b, c, d, e};// 备选数
        int minResult = a * b * c;
        for (int first = 0; first < 3; first++) {
            for (int second = first + 1; second < 4; second++) {
                for (int third = second + 1; third < 5; third++) {
                    int tmpResult = leastMajority(arr[first], arr[second], arr[third]);
                    if (tmpResult < minResult) {
                        minResult = tmpResult;
                    }
                }
            }
        }
        return minResult;
    }

    public static int leastMajority(int a, int b, int c) {
        int result = 1;
        while (result < (a * b * c) && !(result % a == 0 && result % b == 0 && result % c == 0)) {
            result++;
        }
        return result;
    }
}
